package com.masterclient.app.modules.firstpager.fragments.adapters;

import android.graphics.Paint;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.masterclient.app.App;
import com.masterclient.app.R;
import com.eoner.baselibrary.bean.firstpager.NewProductDiscountBean;

import java.util.ArrayList;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * 作者：sean
 * 创建时间：2017/6/16 14:05
 * 功能说明：新品特惠列表
 */

public class NewGoodDiscountAdapter extends BaseQuickAdapter<NewProductDiscountBean.DataBean.ShProductsBean, BaseViewHolder> {

    public NewGoodDiscountAdapter() {
        super(R.layout.item_new_good_discount,new ArrayList<>());
    }

    @Override
    protected void convert(BaseViewHolder helper, NewProductDiscountBean.DataBean.ShProductsBean item) {
        App.picasso.load(item.getSh_image()).fit().into((ImageView) helper.getView(R.id.iv_goods));
        helper.setText(R.id.tv_sub_title,item.getSh_subname());
        helper.setText(R.id.tv_title,item.getSh_name());
        helper.setText(R.id.tv_price_now,"¥"+item.getSh_show_price());
        ((TextView)helper.getView(R.id.tv_price_older)).setPaintFlags(Paint. STRIKE_THRU_TEXT_FLAG| Paint.ANTI_ALIAS_FLAG);
        helper.setText(R.id.tv_price_older,"¥"+item.getSh_line_price());
    }

    static class ViewHolder {
        @BindView(R.id.iv_goods)
        ImageView ivGoods;
        @BindView(R.id.tv_sub_title)
        TextView tvSubTitle;
        @BindView(R.id.tv_title)
        TextView tvTitle;
        @BindView(R.id.tv_price_now)
        TextView tvPriceNow;
        @BindView(R.id.tv_price_older)
        TextView tvPriceOlder;

        ViewHolder(View view) {
            ButterKnife.bind(this, view);
        }
    }
}
